<?php

namespace App\Http\Controllers;

class BaseController extends Controller
{
    /**
     * 成功
     */
    public function success($data = '', $msg = '', $code = 200)
    {
        $result = [
            'code' => $code,
            'data' => $data,
            'msg'  => $msg,
        ];

        return response()->json($result);
    }

    /**
     * 失败
     */
    public function error($msg, $code = 500, $data = '')
    {
        $result = [
            'code' => $code,
            'data' => $data,
            'msg'  => $msg,
        ];

        return response()->json($result);
    }
}
